package o;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import o.czk.g;

public final class dag {
    private static boolean ˏ = false;

    public static boolean ˊ() {
        return ˏ;
    }

    public static void ˎ(boolean z) {
        ˏ = z;
    }

    public static void ˊ(Context context, czt o_czt, cke o_cke) {
        int i = 0;
        if (!ˏ() && !ˏ(o_czt, o_cke) && ˎ(context)) {
            try {
                PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), DnsConfig.MAX_CACHE_ENTRIES);
                if (packageInfo != null) {
                    i = packageInfo.versionCode;
                    int ॱ = euf.ˎ().ॱ("open_predownload_dialog_version", 0);
                    if (ॱ != 0 && ॱ == i) {
                        return;
                    }
                    if (!(ॱ == 0 || ॱ == i)) {
                        euf.ˎ().ˋ("is_need_show_open_predownload_dialog", true);
                    }
                }
                if (o_czt == czt.TYPE_UPDATE_BUTTON) {
                    ˏ(context, i);
                } else if (o_czt == czt.TYPE_INSTALL_BUTTON) {
                    ˎ(context, i);
                } else if (o_czt == czt.TYPE_BATCH_UPDATE_BUTTON) {
                    ˎ(context, i);
                }
            } catch (NameNotFoundException e) {
                czi.ˎ.ˏ("PreDownloadUtils", "GET VERSIONCODE ERROR" + e.toString());
            }
        }
    }

    private static void ˏ(Context context, int i) {
        if (euf.ˎ().ˏ("is_need_show_open_predownload_dialog", true)) {
            ˎ(context, i);
        }
        euf.ˎ().ˋ("is_need_show_open_predownload_dialog", false);
    }

    private static boolean ˎ(Context context) {
        return (cep.ˏ() || cep.ˊ()) && !((czp) dbn.ˎ(czp.class)).ˎ(context);
    }

    private static boolean ˏ(czt o_czt, cke o_cke) {
        return o_czt == czt.TYPE_INSTALL_BUTTON && (o_cke == null || cke.PRE_DOWNLAD_APP != o_cke);
    }

    private static boolean ˏ() {
        return (ˊ() && eqh.ˎ().ˏ()) ? false : true;
    }

    private static void ˎ(final Context context, int i) {
        euf.ˎ().ˊ("open_predownload_dialog_version", i);
        cku ˏ = cku.ˏ(context, cku.class, NetWorkUtil.rebuildWifiKey(context.getString(g.ॱˋ)), NetWorkUtil.rebuildWifiKey(context.getString(g.ˋᐝ)));
        ˏ.ॱ(-1, context.getString(g.ॱˎ));
        ˏ.ॱ(new cks() {
            public void enableNetworking() {
                new czw(context, null).ॱ(true);
            }

            public void upgrade() {
                dag.ˋ(false);
            }

            public void ˋ() {
            }
        });
        ˏ.ˎ(context);
    }

    public static void ˋ(boolean z) {
        czi.ˎ.ˋ("PreDownloadUtils", "setOpenPreUpdate : " + z);
        ((czp) dbn.ˎ(czp.class)).ˋ(ContentManager.getInstant().getContext(), z);
    }
}
